<template>
	<view class="container">
		<!-- 顶部自定义导航栏 -->
		<view class="navbar">
			<view class="title">考试记录</view>
			<view class="icons">
				<view class="icon more"></view>
				<view class="icon circle"></view>
			</view>
		</view>
		<uni-section title="考试记录" type="line">
			<uni-list>
				<uni-list-item v-for="item in recordList" :title="item.paperName" :key="item.id">
					<template #footer>
						<view>
							学科:{{ item.subjectName }} 类型:{{ item.paperType }} 时间:{{ item.createTime }}
							对错:{{ item.questionCorrect }}/{{ item.questionCount }} 得分:{{ item.userScore }}/{{ item.paperScore }}
							耗时:{{ item.doTime }}
						</view>
						<button @click="goToDetail(item.id)">去批改</button>
					</template>
				</uni-list-item>
			</uni-list>
		</uni-section>
	</view>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import http from '../../http.js'
const recordList = ref([])
function goToDetail(id) {
	uni.navigateTo({ url: `/pages/record/detail?id=${id}` })
}
async function fetchRecordList() {
	const res = await http({ url: '/student/exampaper/answer/pageList', method: 'post', data: { pageIndex: 1, pageSize: 10 } })
	if (res && res.response && Array.isArray(res.response.list)) recordList.value = res.response.list
}
onMounted(fetchRecordList)
</script>

<style scoped>
.container {
	background: #fafbfc;
	min-height: 100vh;
}

.navbar {
	width: 100%;
	height: 50px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 16px;
	background: #fff;
	border-bottom: 1px solid #f0f0f0;
}

.title {
	font-size: 20px;
	font-weight: bold;
	color: #222;
}

.icons {
	display: flex;
	align-items: center;
	gap: 12px;
}

.icon.more {
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: #eee;
	display: flex;
	align-items: center;
	justify-content: center;
}

.icon.circle {
	width: 24px;
	height: 24px;
	border-radius: 50%;
	border: 2px solid #222;
}

.list {
	background: #fff;
	margin-top: 8px;
}

.list-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	font-size: 15px;
	color: #222;
	border-bottom: 1px solid #f5f5f5;
}

.list-item:last-child {
	border-bottom: none;
}

.left {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.main {
	font-weight: bold;
	color: #222;
}

.sub {
	font-size: 13px;
	color: #888;
}

.right {
	color: #409eff;
	display: flex;
	align-items: center;
	gap: 4px;
}

.arrow {
	color: #bbb;
	font-size: 18px;
}
</style>
